package com.molichuxing.gateway.exception;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: renzhengyu
 * @Description:
 * @Date: Created in 11:53 2019/10/21
 * @Modified By:
 **/
public enum CarExceptionCodeEnum {

    /**
     * 车辆正在租赁中
     */
    CAR_RENTED(40501, "抱歉，当前车辆正在租赁中，无法继续办理业务"),
    /**
     * 车辆不可租
     */
    CAR_NOT_RENT(40502, "抱歉，当前车辆不可租，无法继续办理业务");

    final static private Map<Integer, CarExceptionCodeEnum> MAP = new HashMap<Integer, CarExceptionCodeEnum>() {
        private static final long serialVersionUID = -8414553247670306999L;
        {
            CarExceptionCodeEnum[] enums = CarExceptionCodeEnum.values();
            for (CarExceptionCodeEnum carExceptionCodeEnum : enums) {
                put(carExceptionCodeEnum.getCode(), carExceptionCodeEnum);
            }
        }
    };

    public static CarExceptionCodeEnum getEnum(Integer code) {
        return MAP.get(code);
    }

    public static String getEnumDesc(Integer code) {
        CarExceptionCodeEnum carExceptionCodeEnum = MAP.get(code);
        if (carExceptionCodeEnum != null) {
            return carExceptionCodeEnum.getMessage();
        }
        return "";
    }

    private Integer code;

    private String message;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    private CarExceptionCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
